﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Nim2D.Components;

namespace Nim2D.Managers {

	public static class EntityManager {

		public static List<Entity> AllEntities;


		static EntityManager() {
			AllEntities = new List<Entity>();
		}


		public static void CreateGenericBusinessGuy(string name, Vector2 pos) {
			// Create the new Entity without components.
			Vars.Entity = new Entity(name, EntityType.GenericBusinessGuy, Vars.Index, true);
			AllEntities.Add(Vars.Entity);
			Vars.Index = AllEntities.IndexOf(Vars.Entity);

			// Use index to relate components to this entity.
			ComponentManager.ComponentDictionaries[ComponentManager.ComponentType.Position].Add(Vars.Index, new Position(pos));
			Vars.Entity.Components.Add(ComponentManager.ComponentType.Position, Vars.Index);
			ComponentManager.ComponentDictionaries[ComponentManager.ComponentType.Appearance].Add(Vars.Index, new Appearance(Engine.Blank, Color.GreenYellow));
			Vars.Entity.Components.Add(ComponentManager.ComponentType.Appearance, Vars.Index);
		}


		public enum EntityType {

			GenericBusinessGuy,
			Developer

		}


		public static void ResetEntities() {
			AllEntities.Clear();
		}

	}

}